@extends('admin.layout._back')

@section('content-header')
@parent
          <h1>
            标签管理
            <small>标签</small>
          </h1>
          <ol class="breadcrumb">
            <li><a href="{{ site_url('dashboard', 'admin') }}"><i class="fa fa-dashboard"></i> 主页</a></li>
            <li><a href="{{ _route('admin:tag.index') }}">标签管理 - 新增分类</a></li>
            <li class="active">新增标签分类</li>
          </ol>
@stop

@section('content')

          @if(session()->has('fail'))
            <div class="alert alert-warning alert-dismissable">
              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
              <h4>  <i class="icon icon fa fa-warning"></i> 提示！</h4>
              {{ session('fail') }}
            </div>
          @endif

          @if($errors->any())
            <div class="alert alert-danger alert-dismissable">
                  <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                  <h4><i class="icon fa fa-ban"></i> 警告！</h4>
                  <ul>
                    @foreach ($errors->all() as $error)
                    <li>{{ $error }}</li>
                    @endforeach
                  </ul>
            </div>
          @endif

              <h2 class="page-header">新增标签</h2>
              <form method="post" action="{{ _route('admin:tag.store') }}" accept-charset="utf-8">
              {!! csrf_field() !!}
              <div class="nav-tabs-custom">
                  <input type="hidden" name="pid" value="{{ $pid }}">
                  <ul class="nav nav-tabs">
                    <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true">主要内容</a></li>
                  </ul>

                  <div class="tab-content">
                    
                    <div class="tab-pane active" id="tab_1">
                      <div class="form-group">
                        <label>标识名 <small class="text-red">*</small> <span class="text-green small">只能为英文和数字</span></label>
                        <input type="text" class="form-control" name="name" autocomplete="off" value="{{ old('name') }}" placeholder="标识名">
                      </div>
                      <div class="form-group">
                        <label>展示名 <small class="text-red">*</small> <span class="text-green small">展示名可以为中文</span></label>
                        <input type="text" class="form-control" name="title" autocomplete="off" value="{{ old('title') }}" placeholder="展示名">
                      </div>
                      <div class="form-group">
                        <label>介绍 <small class="text-red"></small> <span class="text-green small">可不填写</span></label>
                        <input type="text" class="form-control" name="description" autocomplete="off" value="{{ old('description') }}" placeholder="介绍">
                      </div>
                      <div class="form-group">
                        <label>排序 <small class="text-red"></small> <span class="text-green small">可不填写 数字越大排序越前</span></label>
                        <input type="text" class="form-control" name="sort" autocomplete="off" value="{{ old('sort')?old('sort'):0 }}" placeholder="排序">
                      </div>
                      {{--<div class="form-group">--}}
                        {{--<label>关联权限 <small class="text-red">*</small></label>--}}
                        {{--<div class="input-group">--}}
                          {{--@foreach($permissions as $index => $per)--}}
                            {{--@if(starts_with($per->name, '@') && $index !== 0)--}}
                            {{--<br>--}}
                            {{--@endif--}}
                            {{--<input type="checkbox" name="permissions[]" value="{{ $per->id }}">--}}
                            {{--<label class="choice" for="permissions[]" data-value="{{ $per->id }}" style="cursor: pointer;"><span class="text-green">{{ $per->name }}</span>[<span class="text-red">{{ $per->display_name }}</span>]</label>--}}
                          {{--@endforeach--}}
                        {{--</div>--}}
                      {{--</div>--}}
                    </div><!-- /.tab-pane -->

                    <button type="submit" class="btn btn-primary">新增标签分类</button>

                  </div><!-- /.tab-content -->
                  
              </div>
              </form>

@stop

@section('extraPlugin')

  <!--引入iCheck组件-->
  <script src="{{ _asset(ref('icheck.js')) }}" type="text/javascript"></script>

@stop


@section('filledScript')
        <!--启用iCheck响应checkbox与radio表单控件-->
        $('input[name="permissions[]"]').iCheck({
          checkboxClass: 'icheckbox_flat-blue',
          increaseArea: '20%', // optional
        });

        <!--响应点击label 选中或者取消选中-->
        $('label.choice').click(function() {
            var value = $(this).data('value');
            $('input[name="permissions[]"][value='+value+']').iCheck('toggle');
        });
@stop
